<template>
  <div :data="data">
    <el-tag v-if="data.value.people === 1" type="danger"> 有人 </el-tag>
    <el-tag v-else type="success"> 无人 </el-tag>
    <el-button class="filter-item" type="primary" size="mini" style="float:right;" @click="InfraredGetPeople">刷新</el-button>
    <!-- <el-form label-position="left" label-width="80px" :model="value">
      <el-form-item label="人员状态:">
        <el-tag v-if="value.people === 1" type="success"> 有人 </el-tag>
        <el-tag v-else type="danger"> 无人 </el-tag>
      </el-form-item>
    </el-form> -->
  </div>
</template>

<script>

export default {
  name: 'Infrared',
  components: { },
  props: {
    id: {
      type: Number,
      default: 0
    },
    data: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      value: { }
    }
  },
  created() {
  },
  methods: {
    onGet(axis) {
      var message = {
        code: this.value.get_people_code.toString(),
        msg: ''
      }
      this.publish(this.data.sub, JSON.stringify(message))
    },

    // 红外获取是否有人
    InfraredGetPeople() {
      this.data.value.people = 0
      var message = {
        code: this.data.value.code_get_people.toString(),
        msg: '0'
      }
      this.publish(this.data.sub, JSON.stringify(message))
    },

    publish(topic, message) {
      console.log('推送消息')
      console.log('topic:' + topic)
      console.log('message:' + message)
      this.$mqtt.publish(topic, message)
    }

  }
}
</script>

<style lang="scss" scoped>

  .dashboard-editor-container {
    background-color: #e3e3e3;
    min-height: 100vh;
    padding: 50px 60px 0px;
  }
</style>
